<?php
namespace Resmodel;


use Core\Helper\CommonHelper;
use Model\AbstractTable;

use Zend\Db\Adapter\Adapter;
use Core\Session\AdminSessionHelper;
use Zend\Db\Sql\Expression;
use Zend\Db\Sql\Predicate\Like;
use Zend\Db\Sql\Predicate\Operator;
use Zend\Db\Sql\Select;
use Zend\Db\Sql\Sql;


class ResAbstractTable extends AbstractTable
{
    /**
     * @var string
     */
    protected $_domain;
    public function setAdapter($adapter){
        $this->getTableGateway()->setAdapter($adapter);

    }

    /**
     * @param string $domain
     */
    public function setDomain($domain)
    {
        $this->_domain = $domain;
    }

    /**
     * @return string
     */
    public function getDomain()
    {
        return $this->_domain;
    }

    protected   function getMaxOrderNumber(){
        $select =  $this->getDbSqlSelect();
        $select = $select->reset($select::COLUMNS)
            ->reset($select::LIMIT)
            ->reset($select::OFFSET)
            ->reset($select::ORDER)
            ->columns(array('order_number' => new \Zend\Db\Sql\Expression('max(order_number)')));

        $sql = $this->getDbSql();
        $statement = $sql->prepareStatementForSqlObject($select);
        $tmpItem = $statement->execute()->current();

        $dbMaxOrder = $tmpItem['order_number'];
        return $dbMaxOrder;
    }


}